cmake_minimum_required(VERSION 3.21)
project(mprpc)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

add_compile_options("-fPIC")

# deps
find_package(Protobuf REQUIRED)
include(./cmake/utils.cmake)
proto2cpp("${CMAKE_CURRENT_SOURCE_DIR}/example/user.proto" "${CMAKE_CURRENT_SOURCE_DIR}/example")
proto2cpp("${CMAKE_CURRENT_SOURCE_DIR}/example/friend.proto" "${CMAKE_CURRENT_SOURCE_DIR}/example")
proto2cpp("${CMAKE_CURRENT_SOURCE_DIR}/src/rpcheader.proto" "${CMAKE_CURRENT_SOURCE_DIR}/src")

# srcs
include_directories(${PROJECT_SOURCE_DIR}/src/include)
include_directories(${PROJECT_SOURCE_DIR}/example)
link_directories(${PROJECT_SOURCE_DIR}/lib)

add_subdirectory(src)
add_subdirectory(example)

install(TARGETS mprpc
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
    RUNTIME DESTINATION bin
)
install(DIRECTORY "src/include/" DESTINATION include)
